package com.training.admin.entity.project;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang3.StringUtils;
import com.training.admin.entity.trainee.Trainee;


/**
 * 项目-学员
 * @author Rockett
 *
 */
/**
 * @author xiaoHU
 *
 */
@Entity
@Table(name = "project_trainee")
public class ProjectTrainee {
    
	/**
	 * ID
	 */
    @Id
    @GeneratedValue
    private Long id;
    
    /**
     * 项目
     */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Project project;
    
    /**
     * 学员
     */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Trainee trainee;

    /**缺勤天数*/
    private Float absence;
    
    /**成绩*/
    private Float score;
    
    /**
     * 是否结业
     */
    @Column(name = "is_complete" )
    private Boolean complete;
    
    /**
     * 是否补考
     */
    @Column(name = "is_resit" )
    private Boolean resit;
    
    /**
     * 备注
     */
    private String comment;

	@Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * 状态(待定)
     */
	private String status;
	
	/** 现场笔试成绩 */
	private Float spotScore;
	
	/** 面试官认证次数 */
	private Integer  interviewTimes;
	
	/** 面试官认证("未认证", "未通过", "通过") */
	private String interview;
	
	/** 辅导师认证次数 */
	private Integer counselorTimes;
	
	/** 辅导师认证("未认证", "未通过", "通过") */
	private String counselor;
	
	/** 是否种子 */
	private String seed;
	
	/**
     * The default constructor
     */
    public ProjectTrainee() {
    }
    
    /**
     * 
     * @param project
     * @param trainee
     */
    public ProjectTrainee(Project project, Trainee trainee) {
        this.project = project;
        this.trainee = trainee;
        this.disabled = false;
    }
    
    /**
     * @param project
     * @param projectTrainee
     */
    public ProjectTrainee(Project project, ProjectTrainee projectTrainee) {
        this.project = project;
        this.score = projectTrainee.getScore();
        this.absence= projectTrainee.getAbsence();
        this.resit = projectTrainee.getResit();
        this.complete = projectTrainee.getComplete();
        this.comment = projectTrainee.getComment();
        this.trainee = projectTrainee.getTrainee();
    }
    
    /**
     * @param trainee
     * @param complete
     * @param resit
     * @param score
     * @param absence
     * @param comment
     * @param spotScore
     * @param interviewTimes
     * @param interview
     * @param counselorTimes
     * @param counselor
     * @param seed
     */
    public ProjectTrainee(Trainee trainee, String complete, String resit, String score,
                          String absence, String comment, String spotScore, String interviewTimes,
                          String interview, String counselorTimes, String counselor, String seed) {
        this.trainee = trainee;
        this.comment = comment;
        this.score = Float.valueOf(score);
        this.absence = Float.valueOf(absence);
        this.complete = complete.equals("是") ? true : false;
        this.resit = resit.equals("是") ? true : false;
        this.spotScore = StringUtils.isBlank(spotScore) ? null : Float.valueOf(spotScore);
        this.interviewTimes = StringUtils.isBlank(interviewTimes) ? null : Integer.parseInt(interviewTimes);
        this.interview = StringUtils.isBlank(interview) ? null : interview;
        this.counselor = StringUtils.isBlank(comment) ? null : comment;
        this.counselorTimes = StringUtils.isBlank(counselorTimes) ? null : Integer.parseInt(counselorTimes);
        this.seed = seed;
    }
    
    public ProjectTrainee init(Project project, Trainee trainee) {
        this.trainee = trainee;
        this.project = project;
        this.disabled = false;
        return this;
    }
    
    /**
     * @param complete
     * @param resit
     * @param score
     * @param absence
     * @param comment
     * @param spotScore
     * @param interviewTimes
     * @param interview
     * @param counselorTimes
     * @param counselor
     * @param seed
     * @return
     */
    public ProjectTrainee uploadProjectTrainee(Boolean complete, Boolean resit, Float score,
            Float absence, String comment, Float spotScore, Integer interviewTimes,
            String interview, Integer counselorTimes, String counselor, String seed) {
        this.absence = absence;
        this.score = score;
        this.resit = resit;
        this.complete = complete;
        this.comment = comment;
        this.spotScore = spotScore;
        this.interviewTimes = interviewTimes;
        this.interview = interview;
        this.counselorTimes = counselorTimes;
        this.counselor = counselor;
        this.seed = seed;
        return this;
    }
    
    /**
     * 
     * @param complete
     * @param resit
     * @param score
     * @param absence
     * @param comment
     * @return
     */
    public ProjectTrainee uploadProjectTrainee(Boolean complete, Boolean resit, Float score,
            Float absence, String comment) {
        this.absence = absence;
        this.score = score;
        this.resit = resit;
        this.complete = complete;
        this.comment = comment;
        return this;
    }

	/**
	 * 
	 * @return
	 */
	public ProjectTrainee delete() {
		this.disabled = true;
		return this;
	}

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the project
     */
    public Project getProject() {
        return project;
    }

    /**
     * @param project the project to set
     */
    public void setProject(Project project) {
        this.project = project;
    }

    /**
     * @return the trainee
     */
    public Trainee getTrainee() {
        return trainee;
    }

    /**
     * @param trainee the trainee to set
     */
    public void setTrainee(Trainee trainee) {
        this.trainee = trainee;
    }

    /**
     * @return the absence
     */
    public Float getAbsence() {
        return absence;
    }

    /**
     * @param absence the absence to set
     */
    public void setAbsence(Float absence) {
        this.absence = absence;
    }

    /**
     * @return the score
     */
    public Float getScore() {
        return score;
    }

    /**
     * @param score the score to set
     */
    public void setScore(Float score) {
        this.score = score;
    }

    /**
     * @return the complete
     */
    public Boolean getComplete() {
        return complete;
    }

    /**
     * @param complete the complete to set
     */
    public void setComplete(Boolean complete) {
        this.complete = complete;
    }

    /**
     * @return the resit
     */
    public Boolean getResit() {
        return resit;
    }

    /**
     * @param resit the resit to set
     */
    public void setResit(Boolean resit) {
        this.resit = resit;
    }

    /**
     * @return the comment
     */
    public String getComment() {
        return comment;
    }

    /**
     * @param comment the comment to set
     */
    public void setComment(String comment) {
        this.comment = comment;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

    /**
     * @return the status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * @return the spotScore
     */
    public Float getSpotScore() {
        return spotScore;
    }

    /**
     * @param spotScore the spotScore to set
     */
    public void setSpotScore(Float spotScore) {
        this.spotScore = spotScore;
    }

    /**
     * @return the interviewTimes
     */
    public Integer getInterviewTimes() {
        return interviewTimes;
    }

    /**
     * @param interviewTimes the interviewTimes to set
     */
    public void setInterviewTimes(Integer interviewTimes) {
        this.interviewTimes = interviewTimes;
    }

    /**
     * @return the interview
     */
    public String getInterview() {
        return interview;
    }

    /**
     * @param interview the interview to set
     */
    public void setInterview(String interview) {
        this.interview = interview;
    }

    /**
     * @return the counselorTimes
     */
    public Integer getCounselorTimes() {
        return counselorTimes;
    }

    /**
     * @param counselorTimes the counselorTimes to set
     */
    public void setCounselorTimes(Integer counselorTimes) {
        this.counselorTimes = counselorTimes;
    }

    /**
     * @return the counselor
     */
    public String getCounselor() {
        return counselor;
    }

    /**
     * @param counselor the counselor to set
     */
    public void setCounselor(String counselor) {
        this.counselor = counselor;
    }

    /**
     * @return the seed
     */
    public String getSeed() {
        return seed;
    }

    /**
     * @param seed the seed to set
     */
    public void setSeed(String seed) {
        this.seed = seed;
    }

}